package com.hnzq.cloud.freshorderassembly.util;

//import javax.mail.*;
//import javax.mail.internet.InternetAddress;
//import javax.mail.internet.MimeMessage;
import java.util.Properties;
import java.util.Random;

public class CommonsUtil {

    public  String getRandomString(int length) {
        String originString = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM0123456789";
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < length; i++) {
            builder.append(originString.charAt(new Random().nextInt(originString.length())));
        }
        return String.valueOf(builder);
    }

//    public static void sendSecurityCode(String source, String password, String title, String content, String target) throws MessagingException, javax.mail.MessagingException {
//        Properties props = new Properties();
//        props.setProperty("mail.transport.protocol", "SMTP");
//        props.setProperty("mail.host", "smtp.163.com");
//        props.setProperty("mail.smtp.auth", "true");
//        Authenticator authenticator = new Authenticator() {
//            @Override
//            protected PasswordAuthentication getPasswordAuthentication() {
//                return new PasswordAuthentication(source, password);
//            }
//        };
//        Session session = Session.getInstance(props, authenticator);
//        MimeMessage message = new MimeMessage(session);
//        message.setFrom(new InternetAddress(source));
//        message.setSubject(title);
//        message.setContent(content, "text/html;charset=utf-8");
//        message.setRecipient(MimeMessage.RecipientType.TO, new InternetAddress(target));
//        Transport.send(message);
//    }


}
